 //Initialize Select2 Elements





 reload();

function reload(){
	var limit = 100;
	var developerId = $("#developerId").val();
	
	
	var param = {
		developerId : developerId,	
	}
	loading.show();
	$.ajax({
		url:'/dev/getIps',
		type:'GET',
		data:param
	}).done(function(res){
		loading.hide();
		var result = res.value;
		console.log(result);
		var pagefn = doT.template($('#tableDetail01').text());
	    $('#tableList').html(pagefn(result));
	    
	   
        
	}).fail(function(res){
		toast.show(res.errorMsg);
	})
}

function addIp(){
var developerId = $("#developerId").val();
var ip = $("#ip").val();
if(ip==null||ip==''){
	toast.show("ip不能为空");
	return;
}
	cancel('bg');
	var param = {
		developerId : developerId,	
		ip:ip
	}
	loading.show();
		$.ajax({
			url:'/dev/insertIp',
			type:'POST',
			data:param
		}).done(function(res){
			loading.hide();
			if(res.success){
				toast.show("操作成功");
				 $("#ip").val('');
				reload(1);
			}else{
				toast.show(res.errorMsg);
			}
		}).fail(function(res){
			loading.hide();
			toast.show(res.errorMsg);
		})
}

function deleteIp(id){
	getModal.show({content:'确定删除？',cb_l:function(){return deleteIpCb(id)}});
}



function deleteIpCb(id){
	var developerId = $("#developerId").val();
	var param = {
		id:id,
		developerId:developerId,	
	}
	console.log(param)
	$.ajax({
		url:'/dev/deleteIpById',
		type:'POST',
		data:param
	}).done(function(res){
		if(res.success){
			toast.show("操作成功");
			reload(1);
		}else{
			toast.show(res.errorMsg);
		}
	}).fail(function(res){
		toast.show(res.errorMsg);
	})
}




